//
//  AppDelegate.swift
//  soapp
//
//  Created by zhuxietong on 07/17/2017.
//  Copyright (c) 2017 zhuxietong. All rights reserved.
//

import UIKit
import Eelay
import soapp
import RTRootNavigationController
//import Regex

import AsyncDisplayKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    
    func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        __config.build()//对soapp 模块做一些全局性的设置
        ASTableView.open_tpKeyboardAvoiding_swizzle()

//        JPFPSStatus.sharedInstance().open()

//        print(Bundle(for: DB.sqlite.self))
////        let ls = DB.sqlite(db_name: "user.db",bundle: Bundle(for: DB.sqlite.self)).query(sql: "select * from user")
//        soapp_config.build()//对soapp 模块做一些全局性的设置
//        EeNavigationController.open_nav_swizzle()

//        print("++++++++DDD\(UIImage(named: "btn_zoom_in", in: Bundle(for: VideoPlayCelll.self), compatibleWith: nil))")
//
//        print("++DD++++++DDD\(UIImage(named: "nav_back_normal1", in: Bundle(for: VideoPlayCelll.self), compatibleWith: nil))")


//        var str = "<img style=\"width:100px\" src=\"http://ss\"/><img style=\"width:100px\" src=\"http://ss\"/>"
//        let vs = str.replaceAll(matching: "<img(.+?)style(.+?)/>", with: "<img$1_style$2/>")
//        let str1 = Regex("<img(.+)style(.+)/>").firstMatch(in: str)?.captures[0]
        
        
        
//        print("===|\(str)")

//        let vs = "hello world".replacingFirst(matching: "h(ello) (\\w+)", with: "H$1, $2!")
//        print("=====ss|\(str)")
//        let info = Regex("\\S+?<\\S+?>").matches("name<tong>")
//        print("===D\(info)")

        let rawValue = "name<age,page>"

        let value_reg = Regex("(?:<)(\\S*?)(?:>)")
        var value_tag = ""

        let results = value_reg.allMatches(in: rawValue)
        for one in results{
            let value_string = one.captures
            for one_value in value_string{
                if let _value = one_value{
                    value_tag = _value
                }
            }
        }
        let n = rawValue.replacingAll(matching: value_reg, with: "")

        let root = RootNavigationController(rootViewController:  DemoListCtr())
        self.window = UIWindow(frame: UIScreen.main.bounds)
        self.window?.rootViewController = root
        self.window?.makeKeyAndVisible()

//        UIViewController.__swizzing()


        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        __post(notify: AppDelegateNotice.applicationWillResignActive)

        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }
    
    


    func applicationDidEnterBackground(_ application: UIApplication) {
        __post(notify: AppDelegateNotice.applicationDidEnterBackground)

        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        __post(notify: AppDelegateNotice.applicationWillEnterForeground)

        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        __post(notify: AppDelegateNotice.applicationDidBecomeActive)

        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        __post(notify: AppDelegateNotice.applicationWillTerminate)
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

